package org.senseframework.support.open.api.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by lanjian
 */
@Controller
@RequestMapping("/c")
public class ServiceCacheController extends BasicController {

    @ResponseBody
    @RequestMapping(value = "/{service}", method = {RequestMethod.GET})
    public Object serviceCache(@PathVariable String service,
                               @RequestParam(value = "version") String version,
                               @RequestParam(value = "data") String data,
                               HttpServletRequest request, HttpServletResponse response) {
        return handler(service, version, data, null, null, null, null, request, response, null, null, null, null);
    }


    @ResponseBody
    @RequestMapping(value = "/file/{service}", method = {RequestMethod.POST})
    public Object service(@PathVariable final String service,
                          @RequestParam(value = "version") final String version,
                          @RequestParam(value = "data") final String data,
                          @RequestParam(value = "files") final MultipartFile[] files,
                          final HttpServletRequest request, final HttpServletResponse response) {
        return handler(service, version, data, null, null, null, null, request, response, files, null, null, null);
    }


}
